home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group99a.txt / 000201_icon-group-sender _Thu Sep 30 17:34:12 1999.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id RAA28600
  4.     for icon-group-addresses; Thu, 30 Sep 1999 17:33:53 -0700 (MST)
  5. Message-Id: <199910010033.RAA28600@baskerville.CS.Arizona.EDU>
  6. Date: Thu, 30 Sep 1999 17:25:43 -0700
  7. From: Steve Wampler <sbw@tapestry.tucson.az.us>
  8. X-Accept-Language: en
  9. To: icon-group@optima.CS.Arizona.EDU
  10. Subject: A small puzzle
  11. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  12. Status: RO
  13.  
  14.  
  15. I haven't posted anything for a while, but thought this might be fun:
  16.  
  17.    Write an Icon program to generate the pairings in a round-robin
  18.    tournament.  The program should accept the player names as
  19.    command line arguments (see the example below).
  20.  
  21. In a round-robin tournament, every player plays every other player
  22. exactly once.  If there are an odd number of players, then a
  23. special "bye" player is added.
  24.  
  25. For example, given players Alice, Bonnie, and Carole, a sample run
  26. of the program should produce:
  27.  
  28. $ roundrobin Alice Bonnie Carole
  29. Round 1
  30.         Court  1: Alice vs bye
  31.         Court  2: Bonnie vs Carole
  32. Round 2
  33.         Court  1: Alice vs Bonnie
  34.         Court  2: Carole vs bye
  35. Round 3
  36.         Court  1: Alice vs Carole
  37.         Court  2: bye vs Bonnie
  38.  
  39. Naturally, there should be no limit on the number of players.  You can
  40. assume that there are enough courts available to satisfy each round.
  41. (As an additional challenge, implement an optional -n argument, where
  42. n is the number of courts - this is as much an exercise in determining
  43. a reasonable policy for handling the pairing overfow as it is an
  44. exercise in Icon programming.)
  45.  
  46. I have a non-backtracking solution and think I know the way to do
  47. a back-tracking one, but thought others might enjoy playing with this
  48. problem.  Send solutions to me (or back to icon-group) - I'll be
  49. happy to look at them and summarize.  Speed isn't much of
  50. a concern - though randomly producing pairings and rejecting bad ones
  51. probably isn't going to win great praise!
  52.  
  53. Finally, if you really have too much time on your hand, add code to
  54. produce a scoresheet suitable for recording the results. I'd prefer
  55. it if you provided this separately, to keep the size of the solutions
  56. to the original problem down...
  57.  
  58. -- 
  59. ---
  60. Steve Wampler     {sbw@tapestry.tucson.az.us}
  61. The gods that smiled upon your birth are laughing now. -- fortune cookie
  62.